package kr.pe.johnkim.chattingday.mobile.rest.dao;

import kr.pe.johnkim.chattingday.mobile.domain.ChattingDayGatheringWarning;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * Chatting Day 채팅방 신고 관련 DAO 메소드들을 구현하는 클래스 이다.
 * 
 * @author : johnkim <cale9797@gmail.com / Bettersoft Inc,.>
 * @Date : 12. 6. 12
 */
public class ChattingDayGatheringWarningDaoImpl extends SqlMapClientDaoSupport implements ChattingDayGatheringWarningDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(ChattingDayGatheringWarningDaoImpl.class);
    
    /**
     * 불량 채팅방을 신고 한다.
     *
     * @param chattingDayGatheringWarning
     * @return
     */
    @Override
    public boolean registerGatheringWarning(ChattingDayGatheringWarning chattingDayGatheringWarning) {
        logger.info("registerGatheringWarning");

        boolean result;

        try {
            getSqlMapClientTemplate().insert("CHATTINGDAY_GATHERING_WARNING.registerGatheringWarning", chattingDayGatheringWarning);
            result = true;
        } catch (Exception e) {
            result = false;
        }

        return result;
    }

    /**
     * 불량 채팅방 신고했던 것을 비활성화 한다.
     *
     * @param chattingDayGatheringWarning
     * @return
     */
    @Override
    public boolean updateDeactivateGatheringWarning(ChattingDayGatheringWarning chattingDayGatheringWarning) {
        logger.info("updateDeactivateGatheringWarning");

        boolean result;

        try {
            getSqlMapClientTemplate().update("CHATTINGDAY_GATHERING_WARNING.updateDeactivateGatheringWarning", chattingDayGatheringWarning);
            result = true;
        } catch (Exception e) {
            result = false;
        }

        return result;
    }

    /**
     * 해당 채팅방의 불량 신고 총 건수를 가져 온다.
     *
     * @param chattingDayGatheringWarning
     * @return
     */
    @Override
    public ChattingDayGatheringWarning selectGatheringWarningCount(ChattingDayGatheringWarning chattingDayGatheringWarning) {
        logger.info("selectGatheringWarningCount");

        return (ChattingDayGatheringWarning)getSqlMapClientTemplate().queryForObject("CHATTINGDAY_GATHERING_WARNING.selectGatheringWarningCount", chattingDayGatheringWarning);
    }
}
